<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class site extends CI_Controller {
	public function index()
	{
            $this->load->model('query_db');

            $data['category']=$this->query_db->CATEGORY_SELECT_ALL();
            $data['sub_category']=$this->query_db->SUB_CATEGORY_SELECT_ALL();

            $this->load->view('welcome',$data);
	}
        public function getKeyWord()
        {
            $like=$this->input->post('LIKEVAL');
            $this->load->model('query_db');
            $data=$this->query_db->getKeyWord($like);
            if(count($data)!=0)
            {
                $html="";
                foreach ($data as $row)
                {
                    $w=$row['WORD'];
                    $html=$html."<li txtVal='$w' class='noleave'><span class='bold noleave'>".substr($w,0,strlen($like))."</span>".substr($w,strlen($like),strlen($w))."</li>";
                }
                $html=$html."
                <script>$('.search-list li').click(function(){
                    var vals=$(this).attr('txtVal');
                    $('#txtSearchValue').val(vals);
                    ReturnSearchInput();
                });</script>";                
                echo $html;
            }
            else { echo ""; }
        }
}